<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>光谱分析报告</title>
<%-- 全站样式 --%>
<jsp:include page="/WEB-INF/jsps/template_style.jsp"></jsp:include>

</head>

<body class="page-body skin-navy">
	<div class="page-container">
		<%--侧边栏 --%>
		<jsp:include page="/WEB-INF/jsps/sidebar.jsp"></jsp:include>

		<div class="main-content">
			<%--导航栏 --%>
			<jsp:include page="/WEB-INF/jsps/navbar.jsp"></jsp:include>

			<div class="page-title">
				<div class="title-env">
					<h1 class="title">光谱分析报告</h1>
					<p class="description">您可以在此页面上查看检测物质的分析报告</p>
				</div>
			</div>

			<div class="row">
				<div class="col-md-12 gallery-right">
					<!-- Default panel -->
					<div class="panel panel-default">
						<!-- Add class "collapsed" to minimize the panel -->
						<div class="panel-heading">
							<h3 class="panel-title">被检测物</h3>
							<div class="panel-options">
								<a href="#" data-toggle="panel"> <span class="collapse-icon">&ndash;</span>
									<span class="expand-icon">+</span>
								</a>
							</div>
						</div>
						<div class="panel-body">
							<p>
								<strong>被检测物名称：</strong>${detected.detectedName}</p>
							<p>
								<strong>被检测物内容：</strong>
								<c:forEach var="content" items="${contentDetail }">
								    ${content.name }
								</c:forEach>
								</p>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-md-12">
					<!-- Collapsed panel -->
					<div class="panel panel-default">
						<!-- Add class "collapsed" to minimize the panel -->
						<div class="panel-heading">
							<h3 class="panel-title">光谱分析报告</h3>
							<!-- Invoice Options Buttons -->
							<div class="invoice-options hidden-print panel-options">
								<a href="javascript:;" onclick="window.print();"
									class="btn btn-block btn-secondary btn-icon btn-icon-standalone btn-icon-standalone-right btn-single text-left">
									<i class="fa-print"></i> <span>打印</span>
								</a>
							</div>
							<div class="panel-options">
								<a href="#" data-toggle="panel"> <span class="collapse-icon">–</span>
									<span class="expand-icon">+</span>
								</a>
							</div>
						</div>
						<div class="panel-body">
							<section class="invoice-env">
							<table class="table table-bordered">
								<thead>
									<tr class="no-borders">
										<th class=" hidden-xs">被检测物：${detected.detectedName}</th>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<th class="hidden-xs">检测地：${report.categoryOrigin }</th>
									</tr>
									<tr class="no-borders">
										<th class=" hidden-xs">检测物类别：${secondaryClassification }</th>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<th class=" hidden-xs">检测时间：${report.checkTime }</th>
									</tr>
									<tr class="no-borders">
										<th class=" hidden-xs">检测光谱：${report.spectrumTypeName }</th>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<th class=" hidden-xs">采用标准：${report.standards }</th>
									</tr>

									<tr class="no-borders">
										<th class="text-center hidden-xs">序号</th>
										<th width="20%" class="text-center">检测内容名称</th>
										<th width="10%" class="text-center">测试结果</th>
										<th width="10%" class="text-center">单位</th>
										<th width="15%" class="text-center">参考值</th>
										<th class="text-center hidden-xs">是否超标</th>
									</tr>
								</thead>
								<tbody id="report">
									<%
									    int i = 0;
									%>
									<c:forEach var="content" items="${contentDetail }">
										<tr>
											<td class="text-center hidden-xs"><%=++i%></td>
											<td>${content.name}</td>
											<td class="text-center hidden-xs" id="con">${content.value}</td>
											<td class="text-center hidden-xs" id="unit"></td>
											<td class="text-center hidden-xs">${content.standardValue}</td>
											<td class="text-center hidden-xs"><c:choose>
													<c:when test="${content.isExcessive == 0}"> 
                                                                                                                                                                  否
													</c:when>
													<c:otherwise>
                                                                                                                                                                    是
													</c:otherwise>
												</c:choose></td>
										</tr>
									</c:forEach>
								</tbody>
								<thead>
									<tr class="no-borders">
										<th class="text-center hidden-xs">分析员：${sessionScope.session_user.name}</th>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<th class="text-center hidden-xs">是否合格：<c:choose>
												<c:when test="${report.regular == 0}"> 
                                                                                                                                                                  合格
                                                    </c:when>
												<c:otherwise>
                                                                                                                                                                    不合格
                                                    </c:otherwise>
											</c:choose></th>
									</tr>
								</thead>
							</table>
							</section>
						</div>
					</div>
				</div>
			</div>

			<section class="gallery-env">
			<div class="row">
				<div class="col-md-12">
					<div class="album-header">
						<h2>光谱图像</h2>

						<ul class="album-options list-unstyled list-inline">
							<li><a href="/downSpectrumPicture.do?spectrumPicture=${report.spectrumPicture }"> <i class="fa-download"></i> 下载谱图
							</a></li>
						</ul>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-12">
					<img src="${report.spectrumPicture }" />
				</div>
			</div>
			</section>
			<%--页脚 --%>
			<jsp:include page="/WEB-INF/jsps/footer.jsp"></jsp:include>
		</div>
	</div>

	<div class="page-loading-overlay ">
		<div class="loader-2 "></div>
	</div>
	<!-- Gallery Delete Image (Confirm)-->
	<div class="modal fade" id="gallery-image-delete-modal" data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">

				<div class="modal-header">
					<h4 class="modal-title">Confirm Image Deletion</h4>
				</div>

				<div class="modal-body">Do you really want to delete this image?</div>

				<div class="modal-footer">
					<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
					<button type="button" class="btn btn-danger">Delete</button>
				</div>
			</div>
		</div>
	</div>

	<%-- 尾部内容 --%>
	<jsp:include page="/WEB-INF/jsps/template_tail.jsp" />

	<!--Specific JS for this page-->
	<script type="text/javascript">
	   var trList = $("#report").children("tr");
	   for(var i=0; i<trList.length; i++) {
		   var tdArr = trList.eq(i).find("td");
		   var value = tdArr.eq(2).text();
	       var unit1 = unit(value);
	        tdArr.eq(3).text(unit1);
	        console.log(value)
	   }
	   
	   function unit(value) {
		   var index = "";
           for (var i = value.length - 1; i > 0; i--) {
               var str = value[i];
               var r = /^[0-9]+.?[0-9]*$/;
               if (r.test(str)) {
                   index = i;
                   break;
               }
           }
           var unit = value.substring(index + 1, value.length);
           return unit;
	   }
		
	</script>

</body>

</html>